#include "common.h"

layout(location = TEXCOORD0) in vec2 vTex0;
layout(location = COLOR0) in vec4 vColor;

layout(location = COLOR0) out vec4 oColor;

//	TODO: OGL: move to load instead of sample (will need to provide integer texture coordinates)
#define EPS	(0.9f/255.f)
#define CLIP_THRESHOLD	(1.0f/255.f)
void main ()
{
  	// Sample the fat framebuffer:
  	half4	NH		= tex2D( s_normal, vTex0); 
  	half	L 		= NH.w * dot( Ldynamic_dir.xyz, NH.rgb ) + EPS; // Use hemisphere as approximation of max light

	clip(L-CLIP_THRESHOLD);

  	oColor			= half4( L, L, L, L );
}
